package com.example.counter.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class hello {

    @Autowired
    StringRedisTemplate template;

    @GetMapping({"/index","/"})
    public   @ResponseBody String index()
    {
        Long views = template.opsForValue().increment("views");
        return "hello!你是第"+views+"个访问本站的人";
    }
}
